#include <cctype>
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string str;
	getline(cin, str);
	char c;
	cin >> c;
	if (islower(c)) // 全部小写字母转大写
	{
		c -= 32;
	}
	int cnt = 0;
	for (auto& e : str)
	{
		if (islower(e))
			e -= 32;
		if (e == c)
			++cnt;
	}
	cout << cnt;
	return 0;
}